package main

import (
	"dh.com/store/srv/log/handler"
	"dh.com/store/srv/log/subscriber"
	"github.com/micro/go-micro"
	"github.com/micro/go-micro/registry/etcd"
	"github.com/micro/go-micro/util/log"
	"github.com/micro/go-plugins/broker/redis"

	log1 "dh.com/store/srv/log/proto/log"
)

func main() {
	// New Service
	service := micro.NewService(
		micro.Name("com.dh.store.srv.log"),
		micro.Version("latest"),
		micro.Registry(etcd.NewRegistry()),
		micro.Broker(redis.NewBroker()),
	)

	// Initialise service
	service.Init()

	// Register Handler
	log1.RegisterLogHandler(service.Server(), new(handler.Log))

	//// Register Struct as Subscriber
	micro.RegisterSubscriber("com.dh.store.srv.log", service.Server(), new(subscriber.Log))

	// Register Function as Subscriber
	micro.RegisterSubscriber("com.dh.store.srv.log", service.Server(), subscriber.Handler)

	// Run service
	if err := service.Run(); err != nil {
		log.Fatal(err)
	}
}
